package com.wzy.Jdbc封装.controller;

import com.wzy.Jdbc封装.pojo.News_comment;
import com.wzy.Jdbc封装.service.Impl.option_News_commentImpl;
import com.wzy.Jdbc封装.service.option_News_comment;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class News_commentController {
    //注入服务层
    private static option_News_comment news_comment = new option_News_commentImpl();

    //根据id查询信息
    public static void select(News_comment comment)throws SQLException{
        List<News_comment> list = news_comment.selectById(comment);
        for (News_comment c : list){
            System.out.println(c.getId()+"-------"+c.getNewsId()+"-------"+c.getContent()+"-------"+c.getAuthor()+"-------"+c.getIp()+"-------"+c.getDate());
        }
    }

    //根据id删除信息
    public  static  void delete(News_comment comment) throws SQLException {
        int i = news_comment.deleteById(comment);
        System.out.println(i>0?"删除成功":"删除失败");
    }

    //根据id修改名称name
    public  static  void update(News_comment comment) throws SQLException {
        int i = news_comment.updateById(comment);
        System.out.println(i>0?"修改成功":"修改失败");
    }

    //新增信息
    public  static  void insert(News_comment comment) throws SQLException {
        int i = news_comment.insertNews(comment);
        System.out.println(i>0?"新增成功":"新增失败");
    }

}
